const util = require('../utils/util.js')
const wxRequest = require('../utils/wx-request.js')
const url = require('../utils/api-config.js')






module.exports = {
  //登录，获取token
   requestPostLanderToken : function (wx_login_code, wx_user_info, code200) {
    let data = {
      wx_login_code: wx_login_code,
      wx_user_info: wx_user_info
    }
    wxRequest.POST(url.post_lander_token, data, code200)
  },


// 房源
 requestToAddHouse : function (area, house_name, code200) {
    let data = {
      area: area,
      house_name: house_name
    }
    wxRequest.POST(url.houses, data, code200)
  },

 requestToGetHouse: function (code200) {
   let data = {

   }
   wxRequest.GET(url.houses, data, code200)
 },


//  账本
 requestToAddBook: function (book, code200) {
  //  house_id, renter_phone, renter_name, rent_begin_date, rent_month_count, pay_in_day, pay_month_count, money_secure, money_per_month
   let data = {
     house_id: book.house_id,
     renter_phone: book.renter_phone,
     renter_name: book.renter_name,
     rent_begin_date: book.rent_begin_date,
     rent_month_count: book.rent_month_count,
     pay_in_day: book.pay_in_day,
     pay_month_count: book.pay_month_count,
     money_secure: book.money_secure,
     money_per_month: book.money_per_month,
   }
   wxRequest.POST(url.books, data, code200)
 },

 requestToGetHouseBook: function (code200) {
   let data = {

   }
   wxRequest.GET(url.books, data, code200)
 },

 requestToGetWxPayData: function (code200) {
   let data = {

   }
   wxRequest.GET(url.wx_pay_data, data, code200)
 },

 requestToGetBill: function (book_id, trade_state, code200) {
   let data = {
     book_id: book_id,
     trade_state: trade_state
   }
   wxRequest.GET(url.to_bills, data, code200)
 },

 requestPutBillToClosed: function (bill_id, moneyday, moneyway, code200){
   let data = {
     bill_id: bill_id,
     moneyday: moneyday,
     moneyway: moneyway
   }
   wxRequest.PUT(url.to_bills, data, code200)
 },

 requestToDeleteHouse: function (house_id, code200) {
   let data = {
   }
   wxRequest.DELETE(url.houses + "/" + house_id, data, code200)
 },

 requestToDeleteBook: function (book_id, code200) {
   let data = {
   }
   wxRequest.DELETE(url.books + "/" + book_id, data, code200)
 },


 requestToGetAccount: function (code200) {
   let data = {
   }
   wxRequest.GET(url.to_accounts, data, code200)
 },

 requestToPutAccountBalance: function (amount,code200) {
   let data = {
     amount: amount
   }
   wxRequest.PUT(url.to_accounts, data, code200)
 },

 requestToGetCashOrder: function (code200) {
   let data = {
   }
   wxRequest.GET(url.to_cashorder, data, code200)
 },


 requestToGetCashOrderDetail: function (cash_order_id,code200) {
   let data = {
   }
   wxRequest.GET(url.to_cashorder + "/" + cash_order_id, data, code200)
 },
 
 requestToPutBook: function (rent_month_count, money_per_month, book_id, code200) {
   //  house_id, renter_phone, renter_name, rent_begin_date, rent_month_count, pay_in_day, pay_month_count, money_secure, money_per_month
   let data = {
     rent_month_count: rent_month_count,
     money_per_month: money_per_month,
   }
   wxRequest.PUT(url.books + "/" + book_id, data, code200)
 },

 requestToGetBookDetail: function (book_id, code200) {
   //  house_id, renter_phone, renter_name, rent_begin_date, rent_month_count, pay_in_day, pay_month_count, money_secure, money_per_month
   let data = {
    
   }
   wxRequest.GET(url.books + "/" + book_id, data, code200)
 },


 
}